#ifndef GAMEENGINE_GRAPHICS_MESHES_TRGL_MESH_IO_H
#define GAMEENGINE_GRAPHICS_MESHES_TRGL_MESH_IO_H

#include <GameEngine/Graphics/graphics_settings.h>

#include <GameEngine/Graphics/Lighting/material.h>

#include <vector>

class QTextStream;
struct Lib3dsNode;
struct Lib3dsFile;


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

class TrglMesh;

//=================================================================================

//! Class for reading and writing triangle meshes from / to files
/*!
 *  This class allows to read / write meshes in different types of file formats, including
 *  the wavefront file format (OBJ files), Gamebryo's NetImmerse file format (NIF files),
 *  AutoDesk's 3D Studio Max file format (3DS files) and a custom raw binary file format
 *  (BIN files).
 */
class _Graphics_decl TrglMeshIO {

public:
	static bool load_obj_file(TrglMesh& mesh, const GEString& file, float scale = 1.0f);
	static bool save_obj_file(const TrglMesh& mesh, const GEString& file);

	static bool load_bin_file(TrglMesh& mesh, const GEString& file, float scale = 1.0f);
	static bool save_bin_file(const TrglMesh& mesh, const GEString& file);

	static bool load_nif_file(TrglMesh& mesh, const GEString& file, float scale = 1.0f);
	static bool save_nif_file(const TrglMesh& mesh, const GEString& file);

	static bool load_3ds_file(TrglMesh& mesh, const GEString& file, float scale = 1.0f);
	static bool save_3ds_file(const TrglMesh& mesh, const GEString& file);

protected:
	static bool load_mtl_file(std::vector<Material>& materials, std::vector<bool>& materials_transparency, const GEString& file, const GEString& dir_path);
	static bool load_mtl(std::vector<Material>& materials, std::vector<bool>& materials_transparency, const GEString& material_name, QTextStream& in, const GEString& dir_path);

	static bool load_3ds_nodes(TrglMesh& mesh, Lib3dsFile* f, Lib3dsNode* node, const GEString& dir_path, float scale);
};

//=================================================================================


#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif

#endif
